package com.exception.global.controller;

import com.exception.global.exception.CustomException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 */
@RestController
public class ExceptionController {

    private static final Logger log = LoggerFactory.getLogger(ExceptionController.class);


    @GetMapping("test")
    public String test() {
        int i = 10/0;
        return i + ": exceptionInfo";
    }

    @GetMapping("test2")
    public String test2(Integer num) {
        log.info("测试第一个参数：{}，第二个参数：{}，第三个参数：{}", "123","abc","123hyu");
        if (num == null) {
            throw new CustomException("400", "数值为null");
        }
        int i = 10 / num;
        return "test2: " + num;
    }
}
